package cn.dogeye.util;

import cn.hutool.json.JSONUtil;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public final class RespUtil {
    public static void write(HttpServletResponse response,Object s) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        PrintWriter writer = response.getWriter();
        if(s instanceof String)
            writer.write((String) s);
        else
            writer.write(JSONUtil.toJsonStr(s));
        writer.flush();
        writer.close();
    }
}
